package com.microservice.demo.web;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import com.microservice.demo.domain.User;
import com.microservice.demo.repository.UserRepository;

@RestController
public class UserController {

	@Autowired
	private UserRepository userRepository;
	
	@GetMapping("/getUser/{id}")
	public User getUserById(@PathVariable("id") Long id) {
	    User user = userRepository.findOne(id);
		return user;
	}
	@GetMapping("/getUserList/{ids}")
	public List<User>  getUserListByIds(@PathVariable("ids") List<Long> ids) {
		List<User> users = userRepository.findAll(ids);
		return users;
	}
}
